package com.meiya.baseweb.dao;

import java.util.Collection;
import java.util.List;

import com.meiya.baseweb.common.Page;
import com.meiya.baseweb.common.Page.Sort;
import com.meiya.baseweb.common.PropertyFilter;

public interface Crudable<T> {

	// =============Basic CUD================
	public void newEntity(T t);

	public void deleteEntity(T t);

	public void deleteEntityByPrimarykey(Object primaryKey);

	public void updateEntity(T t);

	// =============Basic R Single================
	public T getEntityByPrimarykey(Object primaryKey);

	public T getEntityByProperties(List<PropertyFilter> filters);

	// =============Basic R List================
	public List<T> getEntitiesByPrimarykeys(Collection<Object> primaryKeys,
			List<Sort> sorts);

	public List<T> findALlEntities(List<Sort> sorts);

	// =============Advanced R List================
	public List<T> findEntitiesByProperties(List<PropertyFilter> filters);

	public List<T> findListOfEntitiesByProperties(List<PropertyFilter> filters,
			Page page);

	public Page findPageOfEntitiesByProperties(List<PropertyFilter> filters,
			Page page);

	public long countPageOfEntities(List<PropertyFilter> filters);
}
